<template>
  <div class="box">
    <el-button type="primary" @click="getReq">get请求</el-button>
    <el-button type="success" @click="postReq">post请求</el-button>
  </div>
</template>

<script>
// 导入axios用来发请求
import axios from "axios";

export default {
  name: "App",
  components: {},
  methods: {
    // 发送get请求
    getReq(){
      axios({
        method:'get',
        url:'https://www.fastmock.site/mock/7a24fbd3721a2bb3ca8b81050909b081/login/api/getUser',
      })
        .then(getRes => {
          console.log(getRes);
          this.$message.success(getRes.data.message)
      });
    },

    // 发送post请求
    postReq(){
      axios({
        method:'post',
        url:'https://www.fastmock.site/mock/7a24fbd3721a2bb3ca8b81050909b081/login/api/updUser',
        data:{ p1 :'参数1', p2 :'参数2'}
      })
        .then(postRes => {
          console.log(postRes);
          this.$message.success(postRes.data.message)
      });
    },
  },
};
</script>

<style>
.box{
  margin: 100px 500px;
}
</style>
